// component/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    setting:{
      type:Object,
      value: null
    },
    naxtTeamplat: {
      type:Object,
      value: null
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    image:["/images/bg.png","/images/bg.png","/images/bg.png","/images/bg.png"],
    swiperCurrent: 0
  },

  /**
   * 组件的方法列表
   */
  methods: {
    swiperChange(e) {
      const that = this;
      that.setData({
        swiperCurrent: e.detail.current
      })
    }, 
    navigatorClickBabber: function(t) {
      var e = t.type == 'navigatorClickBabber' ? t.detail.currentTarget.dataset.url : t.currentTarget.dataset.url;
      var ee = function(t) {
        var a = /([^&=]+)=([\w\W]*?)(&|$|#)/g,
          e = /^[^\?]+\?([\w\W]+)$/.exec(t),
          i = {};
        if (e && e[1])
          for (var o, r = e[1]; null != (o = a.exec(r));) i[o[1]] = o[2];
        return i;
      }(e)
      var open_type = t.type == 'navigatorClickBabber' ? t.detail.currentTarget.dataset.open_type : t.currentTarget.dataset.open_type;
      if (open_type == 'wxapp') {
        var extraData = function(t) {
          var a = /([^&=]+)=([\w\W]*?)(&|$|#)/g,
            e = /^[^\?]+\?([\w\W]+)$/.exec(t),
            i = {};
          if (e && e[1])
            for (var o, r = e[1]; null != (o = a.exec(r));) i[o[1]] = o[2];
          return i;
        }(decodeURIComponent(ee.path))
        wx.navigateToMiniProgram({
          appId: ee.appId,
          path:decodeURIComponent(ee.path),
          extraData:extraData,
          fail: function () {
            
          }
        })
        return ;
      }
      // babber 链接
      var babber_url = [{
          "pagePath": "pages/index/index"
        },
        {
          "pagePath": "pages/cat/cat"
        },
        {
          "pagePath": "pages/cart/cart"
        },
        {
          "pagePath": "pages/user/user"
        },
        {
          "pagePath": "pages/posts/index"
        }
      ];
      var is_babber = 0;
      for (var i = 0; i < babber_url.length; i++) {
        if (e.indexOf(babber_url[i].pagePath) != -1) {
          if (ee.cat_id != '') {
            getApp().globalData.tab_cat_id = ee.cat_id;
            is_babber = 1;
          } else {
            is_babber = 1;
          }
  
        }
      }
      if (is_babber) {
        wx.switchTab({
          url: e
        })
      } else {
        wx.navigateTo({
          url: e　　 // 页面 A
        })
      }
  
      return false;
    },
  }
})
